package com.yjhealth.libs.businessdemo.business;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.os.Handler;

import com.yjhealth.libs.businessdemo.R;
import com.yjhealth.libs.businessdemo.databinding.BusinessdemoActivityDemoRefreshBinding;
import com.yjhealth.libs.commonlib.base.activity.BaseListActivity;
import com.yjhealth.libs.core.core.activity.CoreListActivity;

public class DemoRefreshActivity extends BaseListActivity {
    /*Default*/
    /*Util*/
    private Handler handler = new Handler();
    /*Flag*/
    /*View*/
    private BusinessdemoActivityDemoRefreshBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.businessdemo_activity_demo_refresh);
        initLayout();

        showLoadingView();
        handler.postDelayed(runnable, 1000);

    }

    @Override
    protected void initLayout() {
        super.initLayout();

        setLoadMoreEnable(false);
    }

    @Override
    protected void onRefreshView() {
        showLoadingView();
        handler.postDelayed(runnable2, 1000);
    }

    @Override
    protected void onLoadMoreView() {

    }

    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            showErrorView(null, null);
        }
    };

    private Runnable runnable2 = new Runnable() {
        @Override
        public void run() {
            restoreView();
//            showEmptyView();
        }
    };

    @Override
    protected void onDestroy() {
        super.onDestroy();
        handler.removeCallbacks(runnable);
        handler.removeCallbacks(runnable2);
    }
}
